package com.hwtx.form.domain.def;

import lombok.Data;
import lombok.Getter;

@Data
public class FormProperties {

    public static final String FORM_META = "meta";
    static final String FORM_ITEM_VALIDATION = "validations";
    static final String FORM_TYPE = "form";
    static final String FORM_ITEM_NAME = "name";
    static final String FORM_ITEM_LABEL = "label";
    static final String FORM_ITEM_HIDDEN = "hidden";
    static final String FORM_ITEM_TYPE = "type";
    static final String FORM_ITEM_REQUIRED = "required";
    static final String FORM_ITEM_PRECISION = "precision";
    protected Long formId;
    protected String type;
    protected Boolean system;
    protected String name;
    private int classify;
    private String updateTime;
    private String title;
    private Meta meta;
    private boolean config;

    public enum MetaType {
        LIST,
        FORM;

        public static MetaType of(String value) {
            for (MetaType item : MetaType.values()) {
                if (item.name().equals(value)) {
                    return item;
                }
            }
            return null;
        }
    }

    @Getter
    public static class Meta {
        private String title;
        private MetaType type;
        private String genBy;
        private String appendTo;
        private String createBy;

        public Meta type(MetaType type) {
            this.type = type;
            return this;
        }

        public Meta genBy(String genBy) {
            this.genBy = genBy;
            return this;
        }

        public void appendTo(String appendTo) {
            this.appendTo = appendTo;
        }

        public Meta title(String title) {
            this.title = title;
            return this;
        }
        public Meta createBy(String createBy) {
            this.createBy = createBy;
            return this;
        }
    }
}
